<?php

	/*
	 * AJAX call to call an edit form for editing of a publicity TEXT from the database.
	 * TXTs are stored in the table "publicity".
	 *
	 * Variables:
	 *   id (int) : record ID in the database
	 *              if not given: new TXT.
	 *
	 * Returns: HTML code (string)
	 *
	 */

	$clean["id"] = round($_GET["id"]);
	if($clean["id"] > 0){
		/* A TXT id is provided: load the message */
		$sql = mysql_query("SELECT * FROM publicity WHERE pubID=".$clean["id"]." LIMIT 1");
		if(mysql_num_rows($sql) > 0){
			$row = mysql_fetch_array($sql, MYSQL_ASSOC);
		}
		echo '
		Edit text:<br />
		';
	}
	if(!isset($row)){
		/* No TXT ID was given, or the TXT we tried to load did not exist anymore */
		$row = array("pubText"=>"", "pubFirstdate"=>date("Y-m-d H:i", time()+200));
		echo '
		Add new text:<br />
		';
	}
	echo '
		<textarea id="editbox_textarea" style="width:397px; height: 70px;">'.$row["pubText"].'</textarea><br />
		Show time: <input type="text" id="st" value="'.substr($row["pubFirstdate"],0,16).'" style="width: 110px;" /><br />
		<a href="javascript:edittextclose()" style="display: block; float:left"><img src="'.$url_prefix.'images/cross.png" style="border:0px;" /></a>
		<a href="javascript:edittextsave()" style="display: block; float:right"><img src="'.$url_prefix.'images/disk.png" style="border:0px;" /></a>
		<input type="hidden" id="id" name="id" value="'.$clean["id"].'" />
	';
?>
